package com.cll.prototype.common.config.mybatis.plus;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.dialects.MySqlDialect;
import com.baomidou.mybatisplus.extension.plugins.pagination.optimize.JsqlParserCountOptimize;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 描述信息:
 * MybatisPlus相关配置Bean的管理
 * @author CLL
 * @version 1.0
 * @date 2020/10/14 11:21
 */
@Configuration
public class MybatisPlusConfiguration {


    /**
     * mybatis-plus分页插件
     * @return  分页配置信息
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor page = new PaginationInterceptor();
        //设置分页数据库类型
        page.setDbType(DbType.MYSQL);
        page.setDialect(new MySqlDialect());
        //优化count sql
        page.setCountSqlParser(new JsqlParserCountOptimize(true));
        //设置每页最大值，默认为500
        page.setLimit(100L);
        return page;
    }
}